package dao

import (
	"echo-utils/global"
	"echo-utils/internal/model"

	"xorm.io/xorm"
)

type IlogDao struct {
	engine *xorm.Engine
}

func (s *IlogDao) List() []model.Ilog {
	list := make([]model.Ilog, 0)
	s.engine.Find(&list)
	return list
}

func (s *IlogDao) Add(action string) {
	sets := &model.Ilog{}
	sets.Action = action
	s.engine.Insert(sets)
}

func (s *IlogDao) Clear() {
	s.engine.Where("1=1").Delete(new(model.Ilog))
}

func NewIlogDao() *IlogDao {
	return &IlogDao{
		engine: global.DBEngine,
	}
}
